<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>27.继承对constructor属性的影响</title>
</head>

<body>
</body>
<script>
  function User () { }
  User.prototype.name = function () {
    console.log('user.name');
  }



  function Admin () { }

  Admin.prototype = Object.create(User.prototype);
  //  不赋值 则constructor丢失，返回User构造函数
  Admin.prototype.constructor = Admin;
  Admin.prototype.role = function () {
    console.log('admin role');
  };
  let a = new Admin();
  //    
  let b = new a.__proto__.constructor();
  console.log(a.constructor); // ƒ Admin () { } 不赋值Admin.prototype.constructor  则constructor丢失，返回User构造函数
  console.log(b.constructor); //  ƒ Admin () { } 不赋值Admin.prototype.constructor  则constructor丢失，返回User构造函数


</script>

</html>